import React from 'react'
import RechargeBg from '../../../../components/lift_components/RechargeBg'
import { getrechargeData } from '../../../../fetch/lifeService'
import RechargeSubPage from './SubPage'
import bg05 from '../../../../static/images/life_img/bg_05.png'

export default class RechargeableCard extends React.Component {
  constructor(){
    super();
    this.state = {
      data:[],
      balance:''
    }
  }
  componentDidMount(){
    const result = getrechargeData('1234')
    result.then(data => {
      console.log(data);
      this.setState({
        balance:data.uerinfo.balance,
        data:data.data
      })
    })
  }
  render() {
    return(
      <div>
        {
          this.state.balance.length > 0
          ? <RechargeBg imgUrl={ bg05 } balance={this.state.balance}/>
          :<RechargeBg imgUrl={ bg05 } balance=''/>
        }
        {
          this.state.data.length > 0
          ? <RechargeSubPage data={ this.state.data }/>
          : <div>数据正在加载中...</div>
        }
      </div>
    )
  }
}
